import { Button, Modal, Menu, Card, Form, Radio, Input } from 'antd';
import { useState, useEffect } from 'react'
import xxspDangerDel from '../xxspDengerdel';
import ApprovalInformationList from '../xxspDengerdel/ApprovalInformationList';

import InfoFeedback from '../xxspDengerdel/InfoFeedback';
import FetchHelper from "../../../../../../../utils/helper/fetch-helper";
export default function DangerReport(props) {
    const { currentDelItem, setCurrentDelItem } = props
    const [visible, setVisible] = useState();
    const [openKeys, setOpenKeys] = useState(['1']);
    const [data, setData] = useState('1');

    const [xxfkItem, setXxfkItem] = useState();
    const [open_addXxfk, setOpen_addXxfk] = useState(false);


    const [chaKan, setChaKan] = useState();
    //决定新增还是修改
    const [getORpost, setGetORpost] = useState();
    const [showInput, setShowInput] = useState(false);



    const items = [
        {
            label: '信息反馈',
            key: '1',
            //icon: <MailOutlined />,
        },
        {
            label: '调查管理',
            key: '2',
            // icon: <AppstoreOutlined />,
            //disabled: true,
        },
        {
            label: '排查治理',
            key: '3',
            // icon: <AppstoreOutlined />,
            //disabled: true,
        },
        {
            label: '灾情直报',
            key: '4',
            // icon: <AppstoreOutlined />,
            //disabled: true,
        },
        {
            label: '隐患点管理',
            key: '5',
            // icon: <AppstoreOutlined />,
            //disabled: true,
        },
        {
            label: '辅助信息',
            key: '6',
            // icon: <AppstoreOutlined />,
            //disabled: true,
        },

    ]


    const onClick = ({ item, key, keyPath, domEvent }) => {
        setData(key);
        setOpenKeys(key);
        //console.log(key,item);
    };

    useEffect(() => {
        //if (item?.id) {
        FetchHelper.getJson(`/admin-api/ybyj/rwb/list`, { rwlx: '信息反馈' }).then(resp => {
            console.log("123112", resp)
            setXxfkItem(resp)
        })


    }, [open_addXxfk, data, getORpost])

    useEffect(() => {
        console.log(getORpost)
        FetchHelper.putJson(`/admin-api/ybyj/rwb`, { ...getORpost?.currentValue, iswc: "查看" }).then(resp => { }).catch(err => { alert("上传失败") })

    }, [chaKan, getORpost])


    return <>
        <Button size="small" type="primary" onClick={e => {
            setVisible(true)
        }}>信息审批</Button>

        <Modal title="信息审批" open={visible} onOk={e => { setVisible(false) }} onCancel={e => { setVisible(false) }} width={800} bodyStyle={{
            //height: 400
        }}>
            {/*  <Tabs defaultActiveKey="1" items={items} onChange={onChange} /> */}
            <Menu openKeys={openKeys} onClick={onClick} mode="horizontal" items={items} />
            <div style={{
                width: 750,
                height: 400,
                //backgroundColor:'red',
            }}>
                {data === '1' && <Card style={{
                    width: "100%",
                    height: "100%",
                    overflow: "auto"
                    //backgroundColor:'red',
                }}><div style={{ display: !open_addXxfk ? 'block' : 'none' }}><div style={{ color: 'GrayText' }}>{xxfkItem?.total !== 0 ? xxfkItem?.rows.map((currentValue, index, array) => {
                    //console.log('@@@@@@@', currentValue)
                    return <>
                        <Card style={{ position: 'relative', marginTop: 10 }}>
                            <Button type='link' onClick={() => {
                                setOpen_addXxfk(true);
                                // from_xxfk.current.setFieldsValue(currentValue); 
                                setGetORpost({ getorpost: 1, currentValue: currentValue })
                            }}>预警反馈信息</Button>
                            <p style={{ whiteSpace: 'pre-line' }}>{currentValue?.bz}</p>
                            <Button type='link' style={{ position: 'absolute', right: 10, bottom: 10, }} onClick={() => { }}>{currentValue.iswc === "完成" ? "已完成" : currentValue.iswc === "查看" ? '已查看' : "待审批"}</Button>
                        </Card>
                    </>
                }) : '暂无反馈信息'}
                </div>
                        {/* <h3><Button type='link' onClick={() => { setOpen_addXxfk(true); setGetORpost({ getorpost: 2 }) }}>建立信息反馈任务</Button></h3> */}
                    </div>

                    <div style={{ display: open_addXxfk ? 'block' : 'none', position: 'relative',width:"100%" }}>
                        <p style={{ whiteSpace: 'pre-line' }}>{getORpost?.currentValue?.bz}</p>
                        <p>预警反馈信息：{getORpost?.currentValue.dcmd}</p>
                        <p>预警应对措施：{getORpost?.currentValue.dcmb}</p>
                        <p>图片：</p>
                        <p>视频：</p>
                        <Form>
                            <Form.Item label='确定预警结果'>
                                <Radio.Group onChange={e=>{setShowInput(e?.target?.value)}}>
                                    <Radio value="灾害"> 灾害 </Radio>
                                    <Radio value="隐患"> 隐患 </Radio>
                                    <Radio value="忽略"> 忽略 </Radio>
                                </Radio.Group>
                            </Form.Item>
                           {showInput==="灾害"&& <Form.Item label=''>
                           <Button className="btn1" type="primary"
                               
                                onClick={() => setOpen_addXxfk(false)}
                            >创建灾害并建立调查任务</Button>
                            </Form.Item>}
                            {showInput==="隐患"&& <Form.Item label=''>
                                <Button className="btn1" type="primary"
                               
                                onClick={() => setOpen_addXxfk(false)}
                            >创建隐患并建立排查任务</Button>
                            </Form.Item>}
                            {showInput==="忽略"&& <Form.Item label=''>
                                <Button className="btn1" type="primary"
                               
                                onClick={() => setOpen_addXxfk(false)}
                            >确定</Button>
                            </Form.Item>}
                        </Form>
                        {/* <div className="layout-h">
                            <Button className="btn1" type="primary"
                                //htmlType="submit"
                                onClick={() => setOpen_addXxfk(false)}
                            >确定</Button>

                            <Button onClick={() => { setOpen_addXxfk(false); }} className="btn2">返回</Button>
                        </div> */}
                    </div>
                </Card>
                }

                {/* 调查管理 */}


                {/* 排查治理 */}


                {/* 排查治理 */}


                {data === '6' && <InfoFeedback data={data} />}
                {data !== '6' && data !== '1' && <ApprovalInformationList data={data} item={currentDelItem} />}
            </div>

            {/* <Input.TextArea rows={10} placeholder='隐患解除原因' /> */}
        </Modal>

    </>;
}